package com.llmcu.source.security.shiro.shiro02;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * 第一个shiro例子
 *
 * @author liuling
 * @date 2024/12/30 6:35
 */
public class ShiroRun {
    public static void main(String[] args) {
        // 密码明文
        String password = "z3";
        // 使用MD5加密
        Md5Hash md5Hash = new Md5Hash(password);
        System.out.println("md5Hash = " + md5Hash);
        // 带盐的MD5加密，盐就是在密码明文后拼接新的字符串，然后再进行加密
        Md5Hash md5HashWithSalt = new Md5Hash(password, "customSaltValue");
        System.out.println("md5HashWithSalt = " + md5HashWithSalt);
        // 带盐多次MD5加密
        Md5Hash md5HashWithSaltMul = new Md5Hash(password, "customSaltValue", 3);
        System.out.println("md5HashWithSaltMul = " + md5HashWithSaltMul);
        // 父类实现MD5加密
        SimpleHash simpleHash = new SimpleHash("MD5", password, "customSaltValue", 3);
        System.out.println("simpleHash = " + simpleHash);


    }

}
